class EventEmitter{
    constructor(){
        this.eventList={
            //'hasHouse':[kang,warp]
            //'hasCar':[cheng]
        }
    }
    on(eventName,cb){
        if(!thise.eventList[eventName]){
            this.eventList[eventName]=[]
        }
         this.eventList[eventName].push(cb)
    }
    emit(eventName){
        if(this.eventList[eventName]){
            const handeler=this.eventList[eventName].slice()
            handeler.forEach((item)=>{
                item()
            })
        }
    }
    off(eventName,cb){
        const callback=this.eventList[eventName]
        const index=callback.indexOf(cb)
        if(index!==-1){
            callback.splice(index,1)
        }
    }
    once(eventName,cb){
        const warp=()=>{
            cb()
            this.off(eventName,warp)
        }
        this.on(eventName,warp)
    }
}

function kang(){
    console.log('康总买房子');
    
}
on('hasHouse',kang)